package com.puppet.building.pojo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Result<T> {
    private Integer code;
    private String msg;
    private T data;

    public static <T> Result<T> ok() {
        return new Result<T>(200, "操作成功，", null);
    }

    public static <T> Result<T> ok(T obj) {
        return new Result<T>(200, "操作成功，", obj);
    }

    public static <T> Result<T> ok(T obj, String msg) {
        return new Result<T>(200, msg, obj);
    }

    public static <T> Result<T> fail() {
        return new Result<T>(500, "操作失败，", null);
    }

    public static <T> Result<T> fail(String msg) {
        return new Result<T>(500, msg, null);
    }


}


